<!-- 入驻成功或失败的页面 -->
<template>
	<view class="success-box">
		<view class="tip-top-box">
			<view class="tip-icon-box" :style="{ backgroundColor: state === '1' ? '#00C9B1' : '#FF2E2E' }">
				<u-icon class="tip-icon" :name="state === '1' ? 'checkmark' : 'close'" color="#FFF" size="40rpx"></u-icon>
			</view>
			<text class="text">{{ state === '1' ? '您已成功入驻' : '入驻失败' }}</text>
			<!-- 入驻失败的原因 -->
			<view class="status-box" v-if="state === '0'">
				<block v-for="(failItem, index) in failDataList" :key="failItem.id"><text>{{index + 1}}.{{failItem.content}}</text></block>
			</view>
		</view>
		<view class="tip-button-box">
			<view class="this-button" @click="backViewClick">{{ state === '1' ? '返回' : '请重新填写' }}</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 传递过来的状态值，假设：0 表示失败，1 表示成功
			state: '',
			// 模拟的入驻失败原因列表数据
			failDataList: [{
				id: 1, 
				content: '律师证件上传有误',
			},{
				id: 2, 
				content: '身份证上传不正确',
			}]
		};
	},
	onLoad(obj) {
		this.state = obj.state;
		if (this.state === '1') {
			// 1 表示成功
			uni.setNavigationBarTitle({
				title: '律师入驻'
			});
		} else {
			uni.setNavigationBarTitle({
				title: '入驻失败'
			});
		}

		console.log(this.state);
	},
	methods: {
		// 页面按钮的点击事件（内部需要判断页面状态）
		backViewClick() {
			// 状态为 1 则入驻成功返回到 “个人中心” 页面
			if (this.state === '1') {
				this.$u.route({
					type: 'tab',
					url: '/pages/my/index' // 跳转到个人中心
				});
			} else {
				// 入驻失败点击按钮则携参跳转到重新填写页面
				this.$u.route({
					type: 'redirect',
					url: '/myPackageA/pages/views/set-lawyer' // 应该需要携参方便查询该条记录
				});
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.success-box {
	width: 750rpx;
	height: 554rpx;
	margin-top: 111rpx;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	align-items: center;
	.tip-top-box {
		min-height: 220rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		.tip-icon-box {
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			// background-color: #FF2E2E;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.text {
			margin: 38rpx 0;
			font-size: 38rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #999999;
		}
	}
}
.tip-button-box {
	.this-button {
		width: 364rpx;
		height: 96rpx;
		line-height: 96rpx;
		border-radius: 48rpx;
		background-color: $u-text-color;
		font-size: 32rpx;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		color: #ffffff;
		text-align: center;
	}
}
.status-box {
	display: flex;
	flex-direction: column;
	justify-content: center;
	font-size: 38rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #999999;
}
</style>
